<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - id:000977,sync:fuzzer2,src:001052.lcov_info_final - src/simplekey.cpp</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../index.html">top level</a> - <a href="index.html">src</a> - simplekey.cpp<span style="font-size: 80%;"> (source / <a href="simplekey.cpp.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">id:000977,sync:fuzzer2,src:001052.lcov_info_final</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">68</td>
            <td class="headerCovTableEntry">68</td>
            <td class="headerCovTableEntryHi">100.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2016-03-13 10:42:47</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">11</td>
            <td class="headerCovTableEntry">11</td>
            <td class="headerCovTableEntryHi">100.0 %</td>
          </tr>
          <tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : #include &quot;scanner.h&quot;</a>
<span class="lineNum">       2 </span>            : #include &quot;token.h&quot;
<span class="lineNum">       3 </span>            : 
<span class="lineNum">       4 </span>            : namespace YAML {
<a name="5"><span class="lineNum">       5 </span>            : struct Mark;</a>
<span class="lineNum">       6 </span>            : 
<span class="lineNum">       7 </span><span class="lineCov">      83510 : Scanner::SimpleKey::SimpleKey(const Mark&amp; mark_, std::size_t flowLevel_)</span>
<a name="8"><span class="lineNum">       8 </span><span class="lineCov">      83510 :     : mark(mark_), flowLevel(flowLevel_), pIndent(0), pMapStart(0), pKey(0) {}</span></a>
<span class="lineNum">       9 </span>            : 
<span class="lineNum">      10 </span><span class="lineCov">      16745 : void Scanner::SimpleKey::Validate() {</span>
<span class="lineNum">      11 </span>            :   // Note: pIndent will *not* be garbage here;
<span class="lineNum">      12 </span>            :   //       we &quot;garbage collect&quot; them so we can
<span class="lineNum">      13 </span>            :   //       always refer to them
<span class="lineNum">      14 </span><span class="lineCov">      16745 :   if (pIndent)</span>
<span class="lineNum">      15 </span><span class="lineCov">        740 :     pIndent-&gt;status = IndentMarker::VALID;</span>
<span class="lineNum">      16 </span><span class="lineCov">      16745 :   if (pMapStart)</span>
<span class="lineNum">      17 </span><span class="lineCov">        740 :     pMapStart-&gt;status = Token::VALID;</span>
<span class="lineNum">      18 </span><span class="lineCov">      16745 :   if (pKey)</span>
<span class="lineNum">      19 </span><span class="lineCov">      16745 :     pKey-&gt;status = Token::VALID;</span>
<a name="20"><span class="lineNum">      20 </span><span class="lineCov">      16745 : }</span></a>
<span class="lineNum">      21 </span>            : 
<span class="lineNum">      22 </span><span class="lineCov">      16613 : void Scanner::SimpleKey::Invalidate() {</span>
<span class="lineNum">      23 </span><span class="lineCov">      16613 :   if (pIndent)</span>
<span class="lineNum">      24 </span><span class="lineCov">       8934 :     pIndent-&gt;status = IndentMarker::INVALID;</span>
<span class="lineNum">      25 </span><span class="lineCov">      16613 :   if (pMapStart)</span>
<span class="lineNum">      26 </span><span class="lineCov">       8934 :     pMapStart-&gt;status = Token::INVALID;</span>
<span class="lineNum">      27 </span><span class="lineCov">      16613 :   if (pKey)</span>
<span class="lineNum">      28 </span><span class="lineCov">      16613 :     pKey-&gt;status = Token::INVALID;</span>
<span class="lineNum">      29 </span><span class="lineCov">      16613 : }</span>
<a name="30"><span class="lineNum">      30 </span>            : </a>
<span class="lineNum">      31 </span>            : // CanInsertPotentialSimpleKey
<span class="lineNum">      32 </span><span class="lineCov">     104849 : bool Scanner::CanInsertPotentialSimpleKey() const {</span>
<span class="lineNum">      33 </span><span class="lineCov">     104849 :   if (!m_simpleKeyAllowed)</span>
<span class="lineNum">      34 </span><span class="lineCov">      18659 :     return false;</span>
<span class="lineNum">      35 </span>            : 
<span class="lineNum">      36 </span><span class="lineCov">      86190 :   return !ExistsActiveSimpleKey();</span>
<span class="lineNum">      37 </span>            : }
<span class="lineNum">      38 </span>            : 
<span class="lineNum">      39 </span>            : // ExistsActiveSimpleKey
<span class="lineNum">      40 </span>            : // . Returns true if there's a potential simple key at our flow level
<a name="41"><span class="lineNum">      41 </span>            : //   (there's allowed at most one per flow level, i.e., at the start of the flow</a>
<span class="lineNum">      42 </span>            : // start token)
<span class="lineNum">      43 </span><span class="lineCov">      86190 : bool Scanner::ExistsActiveSimpleKey() const {</span>
<span class="lineNum">      44 </span><span class="lineCov">      86190 :   if (m_simpleKeys.empty())</span>
<span class="lineNum">      45 </span><span class="lineCov">      20147 :     return false;</span>
<span class="lineNum">      46 </span>            : 
<span class="lineNum">      47 </span><span class="lineCov">      66043 :   const SimpleKey&amp; key = m_simpleKeys.top();</span>
<span class="lineNum">      48 </span><span class="lineCov">      66043 :   return key.flowLevel == GetFlowLevel();</span>
<span class="lineNum">      49 </span>            : }
<span class="lineNum">      50 </span>            : 
<span class="lineNum">      51 </span>            : // InsertPotentialSimpleKey
<a name="52"><span class="lineNum">      52 </span>            : // . If we can, add a potential simple key to the queue,</a>
<span class="lineNum">      53 </span>            : //   and save it on a stack.
<span class="lineNum">      54 </span><span class="lineCov">     104849 : void Scanner::InsertPotentialSimpleKey() {</span>
<span class="lineNum">      55 </span><span class="lineCov">     104849 :   if (!CanInsertPotentialSimpleKey())</span>
<span class="lineNum">      56 </span><span class="lineCov">      21339 :     return;</span>
<span class="lineNum">      57 </span>            : 
<span class="lineNum">      58 </span><span class="lineCov">      83510 :   SimpleKey key(INPUT.mark(), GetFlowLevel());</span>
<span class="lineNum">      59 </span>            : 
<span class="lineNum">      60 </span>            :   // first add a map start, if necessary
<span class="lineNum">      61 </span><span class="lineCov">      83510 :   if (InBlockContext()) {</span>
<span class="lineNum">      62 </span><span class="lineCov">      16826 :     key.pIndent = PushIndentTo(INPUT.column(), IndentMarker::MAP);</span>
<span class="lineNum">      63 </span><span class="lineCov">      16826 :     if (key.pIndent) {</span>
<span class="lineNum">      64 </span><span class="lineCov">      10206 :       key.pIndent-&gt;status = IndentMarker::UNKNOWN;</span>
<span class="lineNum">      65 </span><span class="lineCov">      10206 :       key.pMapStart = key.pIndent-&gt;pStartToken;</span>
<span class="lineNum">      66 </span><span class="lineCov">      10206 :       key.pMapStart-&gt;status = Token::UNVERIFIED;</span>
<span class="lineNum">      67 </span>            :     }
<span class="lineNum">      68 </span>            :   }
<span class="lineNum">      69 </span>            : 
<span class="lineNum">      70 </span>            :   // then add the (now unverified) key
<span class="lineNum">      71 </span><span class="lineCov">      83510 :   m_tokens.push(Token(Token::KEY, INPUT.mark()));</span>
<span class="lineNum">      72 </span><span class="lineCov">      83510 :   key.pKey = &amp;m_tokens.back();</span>
<span class="lineNum">      73 </span><span class="lineCov">      83510 :   key.pKey-&gt;status = Token::UNVERIFIED;</span>
<span class="lineNum">      74 </span>            : 
<span class="lineNum">      75 </span><span class="lineCov">      83510 :   m_simpleKeys.push(key);</span>
<span class="lineNum">      76 </span>            : }
<span class="lineNum">      77 </span>            : 
<a name="78"><span class="lineNum">      78 </span>            : // InvalidateSimpleKey</a>
<span class="lineNum">      79 </span>            : // . Automatically invalidate the simple key in our flow level
<span class="lineNum">      80 </span><span class="lineCov">      47257 : void Scanner::InvalidateSimpleKey() {</span>
<span class="lineNum">      81 </span><span class="lineCov">      47257 :   if (m_simpleKeys.empty())</span>
<span class="lineNum">      82 </span><span class="lineCov">      20541 :     return;</span>
<span class="lineNum">      83 </span>            : 
<span class="lineNum">      84 </span>            :   // grab top key
<span class="lineNum">      85 </span><span class="lineCov">      26716 :   SimpleKey&amp; key = m_simpleKeys.top();</span>
<span class="lineNum">      86 </span><span class="lineCov">      26716 :   if (key.flowLevel != GetFlowLevel())</span>
<span class="lineNum">      87 </span><span class="lineCov">      11256 :     return;</span>
<span class="lineNum">      88 </span>            : 
<span class="lineNum">      89 </span><span class="lineCov">      15460 :   key.Invalidate();</span>
<span class="lineNum">      90 </span><span class="lineCov">      15460 :   m_simpleKeys.pop();</span>
<span class="lineNum">      91 </span>            : }
<span class="lineNum">      92 </span>            : 
<span class="lineNum">      93 </span>            : // VerifySimpleKey
<a name="94"><span class="lineNum">      94 </span>            : // . Determines whether the latest simple key to be added is valid,</a>
<span class="lineNum">      95 </span>            : //   and if so, makes it valid.
<span class="lineNum">      96 </span><span class="lineCov">      43590 : bool Scanner::VerifySimpleKey() {</span>
<span class="lineNum">      97 </span><span class="lineCov">      43590 :   if (m_simpleKeys.empty())</span>
<span class="lineNum">      98 </span><span class="lineCov">      16300 :     return false;</span>
<span class="lineNum">      99 </span>            : 
<span class="lineNum">     100 </span>            :   // grab top key
<span class="lineNum">     101 </span><span class="lineCov">      27290 :   SimpleKey key = m_simpleKeys.top();</span>
<span class="lineNum">     102 </span>            : 
<span class="lineNum">     103 </span>            :   // only validate if we're in the correct flow level
<span class="lineNum">     104 </span><span class="lineCov">      27290 :   if (key.flowLevel != GetFlowLevel())</span>
<span class="lineNum">     105 </span><span class="lineCov">       9392 :     return false;</span>
<span class="lineNum">     106 </span>            : 
<span class="lineNum">     107 </span><span class="lineCov">      17898 :   m_simpleKeys.pop();</span>
<span class="lineNum">     108 </span>            : 
<span class="lineNum">     109 </span><span class="lineCov">      17898 :   bool isValid = true;</span>
<span class="lineNum">     110 </span>            : 
<span class="lineNum">     111 </span>            :   // needs to be less than 1024 characters and inline
<span class="lineNum">     112 </span><span class="lineCov">      17898 :   if (INPUT.line() != key.mark.line || INPUT.pos() - key.mark.pos &gt; 1024)</span>
<span class="lineNum">     113 </span><span class="lineCov">       1153 :     isValid = false;</span>
<span class="lineNum">     114 </span>            : 
<span class="lineNum">     115 </span>            :   // invalidate key
<span class="lineNum">     116 </span><span class="lineCov">      17898 :   if (isValid)</span>
<span class="lineNum">     117 </span><span class="lineCov">      16745 :     key.Validate();</span>
<span class="lineNum">     118 </span>            :   else
<span class="lineNum">     119 </span><span class="lineCov">       1153 :     key.Invalidate();</span>
<span class="lineNum">     120 </span>            : 
<span class="lineNum">     121 </span><span class="lineCov">      17898 :   return isValid;</span>
<a name="122"><span class="lineNum">     122 </span>            : }</a>
<span class="lineNum">     123 </span>            : 
<span class="lineNum">     124 </span><span class="lineCov">      45708 : void Scanner::PopAllSimpleKeys() {</span>
<span class="lineNum">     125 </span><span class="lineCov">      85643 :   while (!m_simpleKeys.empty())</span>
<a name="126"><span class="lineNum">     126 </span><span class="lineCov">      39935 :     m_simpleKeys.pop();</span></a>
<span class="lineNum">     127 </span><span class="lineCov">       5773 : }</span>
<span class="lineNum">     128 </span><span class="lineCov">       6108 : }</span>
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.11</a></td></tr>
  </table>
  <br>

</body>
</html>
